<?php $this->headScript()->captureStart() ?>
$(document).ready(function(){
    var options1 = { 
        type:"POST",
        dataType : "text",
        buttons:$('#mainForm').find("button[name='button']"),
        async : true,
        cache: false,
        success:function(responseText, statusText)
        {
            //alert(responseText);
            var json = jQuery.parseJSON(responseText);
            dialogMessage(json.messages);
            return true;
        },
    };
    var v = jQuery("#mainForm").validate({
        debug: true,
        messages: {
        },
        rules: {
        },
        errorPlacement: function(error, element) {
            if ( element.is(":radio") )
                error.appendTo( element.parent().next().next() );
            else if ( element.is(":checkbox") )
                error.appendTo ( element.next() );
            else
                error.appendTo( element.parent().next() );
        },
        success: function(label) {
            label.addClass("valid").text("Ok!")
        },
        submitHandler: function(form) {
            jQuery(form).ajaxSubmit(options1);
        }
    });
});
<?php $this->headScript()->captureEnd() ?>

<?php echo $this->form;?>

